#include "junix.h"
#include <regex.h>

int main(int argc, char **argv)
{
  char buf[LINE_MAX];
  printf("input regex:");
  scanf("%s",buf);
  printf("You regext:%s\n",buf);
  regex_t pattern;

  int ret = regcomp(&pattern, buf, REG_EXTENDED|REG_NEWLINE);
  if(ret)
    err_sys("regcomp");
  printf("re_nsub:%d\n",pattern.re_nsub);
  regmatch_t *match = calloc( pattern.re_nsub,
			      sizeof(regmatch_t));

  printf("input text:");
  scanf("%s",buf);
  printf("text:%s\n",buf);

  ret = regexec(&pattern, 
		buf,
		pattern.re_nsub, 
		match, 
		0);

  if(!ret)
    printf("match\n");

  return 0;
}

